﻿using Newtonsoft.Json;
using rmTest_Crawler.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace rmTest_Crawler
{
    class Program
    {
        private static Logger logger = new Logger(typeof(Program));
        static void Main(string[] args)
        {
            try
            {
                Console.WriteLine("欢迎来到.net高级班vip课程，今天是Eleven老师为大家带来的爬虫的学习");

                #region 测试DownloadHtml
                //{
                //    string html = HttpHelper.DownloadHtml(@"https://list.jd.com/list.html?cat=9987,653,655", Encoding.UTF8);
                //}
                #endregion

                #region 测试获取分类页
                //{
                //    string html = HttpHelper.DownloadHtml(Constant.JDCategoryUrl, Encoding.UTF8);
                //}
                #endregion


                #region 测试抓取商品列表
                //string testCategory = "{\"Id\":73,\"Code\":\"02f01s01T\",\"ParentCode\":\"02f01s\",\"Name\":\"烟机/灶具\",\"Url\":\"http://list.jd.com/list.html?cat=737,13297,1300\",\"Level\":3}";
                //Category category = JsonConvert.DeserializeObject<Category>(testCategory);
                //ISearch search = new CommoditySearch(category);
                //search.Crawler();
                #endregion

                #region 抓取
                CrawlerCenter.Handler();
                #endregion

            }
            catch (Exception ex)
            {
                logger.Error("异常啦，", ex);
                Console.WriteLine("*****************木有成功**********************");
            }
            Console.ReadLine();
        }
    }
}
